package com.kezesong.leasing.controller.admin;

import com.kezesong.leasing.common.ResponseResult;
import com.kezesong.leasing.controller.BaseController;
import com.kezesong.leasing.controller.request.AddOrderReqBody;
import com.kezesong.leasing.entity.OrderEntity;
import com.kezesong.leasing.service.OrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class OrderManagerController extends BaseController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/getOrderList/{pageSize}/{pageIndex}")
    @ApiOperation(value = "getOrderList", notes = "管理员获取所有订单列表")
    public ResponseResult<List<OrderEntity>> getOrderList( @PathVariable("pageSize") int pageSize,
                                                              @PathVariable("pageIndex") int pageIndex){
        List<OrderEntity> orderList = orderService.getOrderList(pageSize, pageIndex);
        if (null == orderList || orderList.size() == 0){
            return buildNoDataResponse();
        }else {
            ResponseResult<List<OrderEntity>> listResponseResult = buildSucessResponse(orderList);
            return listResponseResult;
        }
    }


}
